<template>
  <a-modal
    :title="title"
    :width="800"
    :visible="visible"
    :okButtonProps="{ props: {disabled: disableSubmit} }"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleOk">
    <a-spin :spinning="confirmLoading">

    <a-table
      ref="table"
      size="middle"
      bordered
      rowKey="id"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="ipagination"
      :loading="loading"
      :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
      @change="handleTableChange">

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>
          <a-divider type="vertical"/>
          <a-dropdown>
            <a class="ant-dropdown-link">
              更多 <a-icon type="down"/>
            </a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a href="javascript:;" @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

    </a-table>

    <!-- 表单区域 -->
    <EduChange-modal ref="modalForm" @ok="modalFormOk"/>

    </a-spin>
  </a-modal>
</template>

<script>
  import EduChangeModal from '@/views/xuecheng/student/modules/EduChangeModal'

  import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  import {getAction} from '@/api/manage'
  import {initDictOptions, filterDictText} from '@/components/dict/JDictSelectUtil'
  export default {
    name: "EduChangeList",
    mixins: [JeecgListMixin],
    components: {
      EduChangeModal,
    },
    data() {
      return {
        title: '学籍异动',
        visible: false,
        disableSubmit: false,
        isShow:false,
        confirmLoading: false,
        description: '信息',
        // 表头
        columns: [
          {
            title: '状态',
            align: "center",
            dataIndex: 'status',
            customRender: (text, record, index) => {
              //字典值替换通用方法
              return filterDictText(this.statusDictOptions, text);
            },
          },
          {
            title: '异动情况',
            align:"center",
            dataIndex: 'statusText'
          },
          // {
          //   title: '备注',
          //   align:"center",
          //   dataIndex: 'remark'
          // },
          // {
          //   title: '创建人姓名',
          //   align:"center",
          //   dataIndex: 'createBy'
          // },
          {
            title: '创建时间',
            align:"center",
            dataIndex: 'createTime'
          },
         {
          title: '操作',
          key: 'operation',
          align: "center",
          width: 130,
          scopedSlots: {customRender: 'action'},
        }],
        url: {
          list: "/student/student/listEduChangeByMainId",
          delete: "/student/student/deleteEduChange",
          deleteBatch: "/student/student/deleteBatchEduChange",
        },
        statusDictOptions:[]
      }
    },
    created() {
      this.initDictConfig()
    },
    methods: {
      initDictConfig() {
        //初始化字典 - 性别
        initDictOptions('xc_edu_status').then((res) => {
          if (res.success) {
            this.statusDictOptions = res.result;
          }
        });
      },
      loadData(arg) {
        if (arg === 1) {
          this.ipagination.current = 1;
        }
        var params = this.getQueryParams();
        getAction(this.url.list, {mainId: params.mainId}).then((res) => {
          if (res.success) {
            this.dataSource = res.result;
          } else {
            this.dataSource = null;
          }
        })
      },
      handleOk(){
        this.visible=false
      },
      getMain(mainId) {
        this.visible=true
        this.queryParam.mainId = mainId;
        this.loadData(1);
      },
      handleAdd: function () {
        this.$refs.modalForm.add(this.queryParam.mainId);
        this.$refs.modalForm.title = "添加学籍异动记录";
      },

      handleAddEduChange(mainId){
        this.queryParam.mainId=mainId
        this.$refs.modalForm.add(mainId);
        this.$refs.modalForm.title = "添加学籍异动记录";
      }
    }
  }
</script>
<style scoped>
  .ant-card {
    margin-left: -30px;
    margin-right: -30px;
  }
</style>
